package com.rd.sys.common.web.interceptor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @desc struts2拦截器 ———— log记录异常
 */
public class Log4Exception extends AbstractInterceptor {

    /** */
    private static final long serialVersionUID = 5525407325186621028L;
    private static final Logger logger = LoggerFactory.getLogger(Log4Exception.class);

    /**
     * Intercept.
     * 
     * @param ai
     *            the ai
     * @return the string
     * @throws Exception
     *             the exception
     * @version
     */
    @Override
    public String intercept(ActionInvocation ai) throws Exception {
        try {
            return ai.invoke();
        } catch (Throwable e) {
            logger.error("Action Invocation Exception:", e);
            return "error";
        }
    }

}
